import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';

import { Api } from '../providers/api';

@Injectable()
export class PubApi {

    constructor(public http: Http, public api: Api) {

    }
    //get 请求
    get(url, callback) {

        var result = this.api.get(url, {}) .map(res => res.json()).subscribe((res) => {
            callback && callback(res);

        });
    }
    //Post 请求
    post(url,result,callback) {
     let obj =   this.api.post(url, result)
            .map(resp => resp.json())
         return obj.subscribe((res)=>{
              callback && callback(res);

         })
    }
}

